﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace displaycongress_desktop
{
    public class LoginDecoder
    {
        private static String pw = "";

        public static Boolean connect(String user, String pass)
        {
            byte[] userBytes = Decoder.decode(Decoder.HexString2Bytes(user));
            byte[] passBytes = Decoder.decode(Decoder.HexString2Bytes(pass));

            String username = Encoding.ASCII.GetString(userBytes);
            String password = Encoding.ASCII.GetString(passBytes);

            // Grant access
            if (pw.Equals(password))
            {
                Console.WriteLine("connected: " + username + " - " + password);
                return true;
            }
            else
            {
                Console.WriteLine("not connected: " + username + " - " + password);
                return false;
            }
        }

        public static void setPassword(String password)
        {
            pw = password;
        }
    }
}
